package com.metagurukul.informer.servlets;
import java.io.*;
import java.sql.SQLException;

import javax.servlet.*;
import javax.servlet.http.*;
import com.metagurukul.informer.service.*;

public class ShowQuestion extends HttpServlet
{
	private static final long serialVersionUID = 1L;
	public void doGet(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException
	{
			try {
				
				String id=request.getParameter("id");
				boolean flag=false;
				RequestDispatcher rd=null;
				if(id==null){
				}
				else if(!isInteger(id)){
				}
				else{
					flag=true;
					ShowQuestionService service=new ShowQuestionService();
					if(service.getData(id,request)){
						rd=request.getRequestDispatcher("/ShowQuestion.jsp");
					}
					else{
						rd=request.getRequestDispatcher("/Error.jsp");
					}
				}
				if(!flag){
					rd=request.getRequestDispatcher("/Error.jsp");
				}
				rd.forward(request,response);
			} catch (SQLException e) {
				response.sendRedirect("Error.jsp");
			}
	}
	public boolean isInteger(String id){
		try{
			Integer.parseInt(id);
			return true;
		}
		catch(NumberFormatException e){
		}
		return false;
	}
}